<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="utf-8" />
        <title>Part.2.D.7-tdd</title>
        <link rel="stylesheet" href="/theme/css/main.css" />

        <!--[if IE]>
            <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
</head>

<body id="index" class="home">
        <header id="banner" class="body">
                <h1><a href="/">PythonTutorials </a></h1>
                <nav><ul>
                    <li><a href="/category/cpp.html">cpp</a></li>
                    <li class="active"><a href="/category/python.html">python</a></li>
                </ul>
                </nav>
        </header><!-- /#banner -->
<section id="content" class="body">
  <article>
    <header>
      <h1 class="entry-title">
        <a href="/Part.2.D.7-tdd.html" rel="bookmark"
           title="Permalink to Part.2.D.7-tdd">Part.2.D.7-tdd</a></h1>
    </header>

    <div class="entry-content">
<footer class="post-info">
        <span>Mon 06 April 2020</span>
<span>| tags: <a href="/tag/python.html">python</a><a href="/tag/progarmming.html">progarmming</a><a href="/tag/excel.html">Excel</a></span>
</footer><!-- /.post-info -->      <h1>测试驱动的开发</h1>
<p>写一个函数，或者写一个程序，换一种说法，其实就是 “实现一个算法” —— 而所谓的 “算法”，Wikipedia 上的定义是这样的：</p>
<blockquote>
<p>In mathematics and computer science, an <strong>algorithm</strong> is an unambiguous specification of how to solve a class of problems. Algorithms can perform <em>calculation</em>, <em>data processing</em>, and <em>automated reasoning tasks</em>.</p>
</blockquote>
<p>“算法”，其实没多神秘，就是 “解决问题的步骤” 而已。</p>
<p>在第二部分的第一章里，我们看过一个判断是否为闰年的函数：</p>
<blockquote>
<p>让我们写个判断闰年年份的函数，取名为 is_leap()，它接收一个年份为参数，若是闰年，则返回 True，否则返回 False。</p>
<p>根据闰年的定义：</p>
<blockquote>
<ul>
<li>年份应该是 4 的倍数；</li>
<li>年份能被 100 整除但不能被 400 整除的，不是闰年。</li>
<li>所以，相当于要在能被 4 整除的年份中，排除那些能被 100 整除却不能被 400 整除的年份。</li>
</ul>
</blockquote>
</blockquote>
<p>不要往回翻！现在自己动手尝试着写出这个函数？你会发现其实并不容易的……</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">is_leap</span><span class="p">(</span><span class="n">year</span><span class="p">):</span>
    <span class="k">pass</span>
</pre></div>


<p>第一步，跟很多人想象得不一样，第一步不是上来就开始写……</p>
<p>第一步是先假定这个函数写完了，我们需要验证它返回的结果对不对……</p>
<p>这种 “通过先想办法验证结果而后从结果倒推” 的开发方式，是一种很有效的方法论，叫做 “Test Driven Development”，以测试为驱动的开发。</p>
<p>如果我写的 <code>is_leap(year)</code> 是正确的，那么：</p>
<blockquote>
<ul>
<li><code>is_leap(4)</code> 的返回值应该是 <code>True</code></li>
<li><code>is_leap(200)</code> 的返回值应该是 <code>False</code></li>
<li><code>is_leap(220)</code> 的返回值应该是 <code>True</code></li>
<li><code>is_leap(400)</code> 的返回值应该是 <code>True</code></li>
</ul>
</blockquote>
<p>能够罗列出以上四种情况，其实只不过是根据算法 “考虑全面” 之后的结果 —— 但你自己试试就知道了，无论多简单的事，想要 “考虑全面” 好像并不容易……</p>
<p>所以，在写 <code>def is_leap(year)</code> 中的内容之前，我只是用 <code>pass</code> 先把位置占上，而后在后面添加了四个用来测试结果的语句 —— 它们的值，现在当然都是 <code>False</code>…… 等我把整个函数写完了，写正确了，那么它们的值就都应该变成 <code>True</code>。</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">IPython.core.interactiveshell</span> <span class="kn">import</span> <span class="n">InteractiveShell</span>
<span class="n">InteractiveShell</span><span class="o">.</span><span class="n">ast_node_interactivity</span> <span class="o">=</span> <span class="s2">&quot;all&quot;</span>

<span class="k">def</span> <span class="nf">is_leap</span><span class="p">(</span><span class="n">year</span><span class="p">):</span>
    <span class="k">pass</span>

<span class="n">is_leap</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">False</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">220</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">400</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
</pre></div>


<div class="highlight"><pre><span></span>False

False

False

False
</pre></div>


<p>考虑到更多的年份不是闰年，所以，排除顺序大抵上应该是这样：</p>
<blockquote>
<ul>
<li>先假定都不是闰年；</li>
<li>再看看是否能被 <code>4</code> 整除；</li>
<li>再剔除那些能被 <code>100</code> 整除但不能被 <code>400</code> 整除的年份……</li>
</ul>
</blockquote>
<p>于是，先实现第一句：“先假定都不是闰年”：</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">IPython.core.interactiveshell</span> <span class="kn">import</span> <span class="n">InteractiveShell</span>
<span class="n">InteractiveShell</span><span class="o">.</span><span class="n">ast_node_interactivity</span> <span class="o">=</span> <span class="s2">&quot;all&quot;</span>

<span class="k">def</span> <span class="nf">is_leap</span><span class="p">(</span><span class="n">year</span><span class="p">):</span>
    <span class="n">r</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="k">return</span> <span class="n">r</span>

<span class="n">is_leap</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">False</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">220</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">400</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
</pre></div>


<div class="highlight"><pre><span></span>False
True
False
False
</pre></div>


<p>然后再实现这部分：“年份应该是 4 的倍数”：</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">IPython.core.interactiveshell</span> <span class="kn">import</span> <span class="n">InteractiveShell</span>
<span class="n">InteractiveShell</span><span class="o">.</span><span class="n">ast_node_interactivity</span> <span class="o">=</span> <span class="s2">&quot;all&quot;</span>

<span class="k">def</span> <span class="nf">is_leap</span><span class="p">(</span><span class="n">year</span><span class="p">):</span>
    <span class="n">r</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="k">if</span> <span class="n">year</span> <span class="o">%</span> <span class="mi">4</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
        <span class="n">r</span> <span class="o">=</span> <span class="bp">True</span>
    <span class="k">return</span> <span class="n">r</span>

<span class="n">is_leap</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">False</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">220</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">400</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
</pre></div>


<div class="highlight"><pre><span></span>True
False
True
True
</pre></div>


<p>现在剩下最后一条了：“剔除那些能被 <code>100</code> 整除但不能被 <code>400</code> 整除的年份”…… 拿一个参数值，比如，<code>200</code> 为例：</p>
<blockquote>
<ul>
<li>因为它能被 <code>4</code> 整除，所以，使 <code>r = True</code>，</li>
<li>然后再看它是否能被 <code>100</code> 整除 —— 能 —— 既然如此再看它能不能被 <code>400</code> 整除，</li>
<li>如果不能，那就让 <code>r = False</code>；</li>
<li>如果能，就保留 <code>r</code> 的值……
如此这般，<code>200</code> 肯定使得 <code>r = False</code>。</li>
</ul>
</blockquote>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">IPython.core.interactiveshell</span> <span class="kn">import</span> <span class="n">InteractiveShell</span>
<span class="n">InteractiveShell</span><span class="o">.</span><span class="n">ast_node_interactivity</span> <span class="o">=</span> <span class="s2">&quot;all&quot;</span>

<span class="k">def</span> <span class="nf">is_leap</span><span class="p">(</span><span class="n">year</span><span class="p">):</span>
    <span class="n">r</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="k">if</span> <span class="n">year</span> <span class="o">%</span> <span class="mi">4</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
        <span class="n">r</span> <span class="o">=</span> <span class="bp">True</span>
        <span class="k">if</span> <span class="n">year</span> <span class="o">%</span> <span class="mi">100</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">year</span> <span class="o">%</span> <span class="mi">400</span> <span class="o">!=</span><span class="mi">0</span><span class="p">:</span>
                <span class="n">r</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="k">return</span> <span class="n">r</span>

<span class="n">is_leap</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">200</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">False</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">220</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
<span class="n">is_leap</span><span class="p">(</span><span class="mi">400</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">True</span>
</pre></div>


<div class="highlight"><pre><span></span>True
True
True
True
</pre></div>


<p>尽管整个过程读起来很直观，但真的要自己从头到尾操作，就可能四处出错，不信你就试试 —— 这一页最下面添加一个单元格，自己动手从头写到尾试试……</p>
<p>当然，Python 内建库中的 <code>datetime.py</code> 模块里的代码更简洁，之前给你看过：</p>
<div class="highlight"><pre><span></span><span class="c1"># cpython/Lib/datetime.py</span>
<span class="k">def</span> <span class="nf">_is_leap</span><span class="p">(</span><span class="n">year</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">year</span> <span class="o">%</span> <span class="mi">4</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="p">(</span><span class="n">year</span> <span class="o">%</span> <span class="mi">100</span> <span class="o">!=</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">year</span> <span class="o">%</span> <span class="mi">400</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">_is_leap</span><span class="p">(</span><span class="mi">300</span><span class="p">)</span>
</pre></div>


<div class="highlight"><pre><span></span>False
</pre></div>


<p>你自己动手，从写测试开始，逐步把它实现出来试试？—— 肯定不能允许你拷贝粘贴，哈哈。</p>
<p>在 Python 语言中，有专门用来 “试错” 的流程控制 —— 今天的绝大多数编程语言都有这种 “试错语句”。</p>
<p>当一个程序开始执行的时候，有两种错误可能会导致程序执行失败：</p>
<blockquote>
<ul>
<li>语法错误（Syntax Errors）</li>
<li>意外（Exceptions）</li>
</ul>
</blockquote>
<p>比如，在 Python3 中，你写 <code>print i</code>，而没有写 <code>print(i)</code>，那么你犯的是语法错误，于是，解析器会直接提醒你，你在第几行犯了什么样的语法错误。语法错误存在的时候，程序无法启动执行。</p>
<p>但是，有时会出现这种情况：语法上完全正确，但出现了<strong>意外</strong>。这种错误，都是程序已经执行之后才发生的（Runtime Errors）—— 因为只要没有语法错误，程序就可以启动。比如，你写的是 <code>print(11/0)</code>：</p>
<div class="highlight"><pre><span></span><span class="k">print</span><span class="p">(</span><span class="mi">11</span><span class="o">/</span><span class="mi">0</span><span class="p">)</span>
</pre></div>


<div class="highlight"><pre><span></span>---------------------------------------------------------------------------

ZeroDivisionError                         Traceback (most recent call last)

&lt;ipython-input-2-5544d98276be&gt; in &lt;module&gt;
----&gt; 1 print(11/0)

ZeroDivisionError: division by zero
</pre></div>


<p>虽然这个语句本身没有语法错误，但这个表达式是不能被处理的。于是，它触发了 <code>ZeroDivisionError</code>，这个 “意外” 使得程序不可能继续执行下去。</p>
<p>在 Python 中，定义了大量的常见 “意外”，并且按层级分类：</p>
<blockquote>
<p>在第三部分阅读完毕之后，可以回来重新查看以下官方文档：<br />
https://docs.python.org/3/library/exceptions.html</p>
</blockquote>
<div class="highlight"><pre><span></span>BaseException
 +-- SystemExit
 +-- KeyboardInterrupt
 +-- GeneratorExit
 +-- Exception
      +-- StopIteration
      +-- StopAsyncIteration
      +-- ArithmeticError
      <span class="p">|</span>    +-- FloatingPointError
      <span class="p">|</span>    +-- OverflowError
      <span class="p">|</span>    +-- ZeroDivisionError
      +-- AssertionError
      +-- AttributeError
      +-- BufferError
      +-- EOFError
      +-- ImportError
      <span class="p">|</span>    +-- ModuleNotFoundError
      +-- LookupError
      <span class="p">|</span>    +-- IndexError
      <span class="p">|</span>    +-- KeyError
      +-- MemoryError
      +-- NameError
      <span class="p">|</span>    +-- UnboundLocalError
      +-- OSError
      <span class="p">|</span>    +-- BlockingIOError
      <span class="p">|</span>    +-- ChildProcessError
      <span class="p">|</span>    +-- ConnectionError
      <span class="p">|</span>    <span class="p">|</span>    +-- BrokenPipeError
      <span class="p">|</span>    <span class="p">|</span>    +-- ConnectionAbortedError
      <span class="p">|</span>    <span class="p">|</span>    +-- ConnectionRefusedError
      <span class="p">|</span>    <span class="p">|</span>    +-- ConnectionResetError
      <span class="p">|</span>    +-- FileExistsError
      <span class="p">|</span>    +-- FileNotFoundError
      <span class="p">|</span>    +-- InterruptedError
      <span class="p">|</span>    +-- IsADirectoryError
      <span class="p">|</span>    +-- NotADirectoryError
      <span class="p">|</span>    +-- PermissionError
      <span class="p">|</span>    +-- ProcessLookupError
      <span class="p">|</span>    +-- TimeoutError
      +-- ReferenceError
      +-- RuntimeError
      <span class="p">|</span>    +-- NotImplementedError
      <span class="p">|</span>    +-- RecursionError
      +-- SyntaxError
      <span class="p">|</span>    +-- IndentationError
      <span class="p">|</span>         +-- TabError
      +-- SystemError
      +-- TypeError
      +-- ValueError
      <span class="p">|</span>    +-- UnicodeError
      <span class="p">|</span>         +-- UnicodeDecodeError
      <span class="p">|</span>         +-- UnicodeEncodeError
      <span class="p">|</span>         +-- UnicodeTranslateError
      +-- Warning
           +-- DeprecationWarning
           +-- PendingDeprecationWarning
           +-- RuntimeWarning
           +-- SyntaxWarning
           +-- UserWarning
           +-- FutureWarning
           +-- ImportWarning
           +-- UnicodeWarning
           +-- BytesWarning
           +-- ResourceWarning
</pre></div>


<p>拿 <code>FileNotFoundError</code> 为例 —— 当我们想要打开一个文件之前，其实应该有个办法提前验证一下那个文件是否存在。如果那个文件并不存在，就会引发 “意外”。</p>
<div class="highlight"><pre><span></span><span class="n">f</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;test_file.txt&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span>
</pre></div>


<div class="highlight"><pre><span></span>---------------------------------------------------------------------------

FileNotFoundError                         Traceback (most recent call last)

&lt;ipython-input-3-5fac19176fe6&gt; in &lt;module&gt;
----&gt; 1 f = open(&#39;test_file.txt&#39;, &#39;r&#39;)

FileNotFoundError: [Errno 2] No such file or directory: &#39;test_file.txt&#39;
</pre></div>


<p>在 Python 中，我们可以用 <code>try</code> 语句块去执行那些可能出现 “意外” 的语句，<code>try</code> 也可以配合 <code>except</code>、<code>else</code>、<code>finally</code> 使用。从另外一个角度看，<code>try</code> 语句块也是一种特殊的流程控制，专注于 “当意外发生时应该怎么办？”</p>
<div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
    <span class="n">f</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;test_file.txt&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span>
<span class="k">except</span> <span class="n">FileNotFoundError</span> <span class="k">as</span> <span class="n">fnf_error</span><span class="p">:</span>
    <span class="k">print</span><span class="p">(</span><span class="n">fnf_error</span><span class="p">)</span>
</pre></div>


<div class="highlight"><pre><span></span>[Errno 2] No such file or directory: &#39;test_file.txt&#39;
</pre></div>


<p>如此这般的结果是：</p>
<blockquote>
<p>当程序中的语句 <code>f = open('test_file.txt', 'r')</code> 因为 <code>test_file.txt</code> 不存在而引发意外之时，<code>except</code> 语句块会接管流程；而后，又因为在 <code>except</code> 语句块中我们指定了 <code>FileNotFoundError</code>，所以，若是 <code>FileNotFoundError</code> 真的发生了，那么，<code>except</code> 语句块中的代码，即，<code>print(fnf_error)</code> 会被执行……</p>
</blockquote>
<p>你可以用的试错流程还有以下变种：</p>
<div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
<span class="k">except</span> <span class="n">built_in_error</span> <span class="k">as</span> <span class="n">name_of_error</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
</pre></div>


<p>或者：</p>
<div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
<span class="k">except</span> <span class="n">built_in_error</span> <span class="k">as</span> <span class="n">name_of_error</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
<span class="k">finally</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
</pre></div>


<p>甚至可以嵌套：</p>
<div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
<span class="k">except</span> <span class="n">built_in_error</span> <span class="k">as</span> <span class="n">name_of_error</span><span class="p">:</span>
    <span class="n">do_something</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">do_something</span><span class="p">()</span>
    <span class="k">except</span> <span class="n">built_in_error</span> <span class="k">as</span> <span class="n">name_of_error</span><span class="p">:</span>
        <span class="n">do_something</span><span class="p">()</span>
<span class="o">...</span>
</pre></div>


<p>更多关于错误处理的内容，请在阅读完第三部分中与 Class 相关的内容之后，再去详细阅读以下官方文档：</p>
<blockquote>
<ul>
<li><a href="docs.python.org/3/tutorial/errors.html">Errors and Exceptions</a></li>
<li><a href="https://docs.python.org/3/library/exceptions.html">Built-in Exceptions</a></li>
<li><a href="https://wiki.python.org/moin/HandlingExceptions">Handling Exceptions</a></li>
</ul>
</blockquote>
<p>理论上，这一章不应该套上这么大的标题：《测试驱动开发》，因为在实际开发过程中，所谓测试驱动开发要使用更为强大更为复杂的模块、框架和工具，比如，起码使用 Python 内建库中的 <a href="https://docs.python.org/3/library/unittest.html">unittest</a> 模块。</p>
<p>在写程序的过程中，为别人（和将来的自己）写注释、写 Docstring；在写程序的过程中，为了保障程序的结果全面正确而写测试；或者干脆在最初写的时候就考虑到各种意外所以使用试错语句块 —— 这些明明是天经地义的事情，却是绝大多数人不做的…… 因为感觉有点麻烦。</p>
<p>这里是 “聪明反被聪明误” 的最好示例长期堆积的地方。很多人真的是因为自己很聪明，所以才觉得 “没必要麻烦” —— 这就好像当年苏格拉底仗着自己记忆力无比强大甚至干脆过目不忘于是鄙视一切记笔记的人一样。</p>
<p>但是，随着时间的推移，随着工程量的放大，到最后，那些 “聪明人” 都被自己坑死了 —— 聪明本身搞不定工程，能搞定工程的是智慧。苏格拉底自己并没完成任何工程，是他的学生柏拉图不顾他的嘲笑用纸笔记录了一切；而后柏拉图的学生亚里士多德才有机会受到苏格拉底的启发，写了《前分析篇》，提出对人类影响至今的 “三段论”……</p>
<p>千万不要因为这第二部分中所举的例子太容易而把自己迷惑了。刻意选择简单的例子放在这里，是为了让读者更容易集中精力去理解关于自己动手写函数的方方面面 —— 可将来你自己真的动手去做，哪怕真的去阅读真实的工程代码，你就会发现，难度还是很高的。现在的轻敌，会造成以后的溃败。</p>
<p>现在还不是时候，等你把整本书都完成之后，记得回来再看这个链接：</p>
<blockquote>
<ul>
<li><a href="https://docs.python.org/3/library/doctest.html">doctest —— Test interactive Python examples</a></li>
<li><a href="https://docs.python.org/3/library/unittest.html">unittest —— Unit testing framework</a></li>
</ul>
</blockquote>
    </div><!-- /.entry-content -->

  </article>
</section>
        <section id="extras" class="body">
                <div class="blogroll">
                        <h2>blogroll</h2>
                        <ul>
                            <li><a href="http://getpelican.com/">Pelican</a></li>
                            <li><a href="http://python.org/">Python.org</a></li>
                            <li><a href="http://jinja.pocoo.org/">Jinja2</a></li>
                            <li><a href="#">You can modify those links in your config file</a></li>
                        </ul>
                </div><!-- /.blogroll -->
                <div class="social">
                        <h2>social</h2>
                        <ul>

                            <li><a href="#">You can add links in your config file</a></li>
                            <li><a href="#">Another social link</a></li>
                        </ul>
                </div><!-- /.social -->
        </section><!-- /#extras -->

        <footer id="contentinfo" class="body">
                <p>Powered by <a href="http://www.maxiaoan.com/">Maxiaoan</a></p>
        </footer><!-- /#contentinfo -->

</body>
</html>